//
//  LGHospitalPlanDetailHead.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/5/25.
//  计划详情

#import "LGHospitalPlanDetailHead.h"

@interface LGHospitalPlanDetailHead()

/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UIButton *dateBtn;
/**   */
@property (nonatomic , strong)UIImageView *nameIcon;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *ageLabel;
/**   */
@property (nonatomic , strong)UIButton *numberBtn;

@end

@implementation LGHospitalPlanDetailHead

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setTypeTitle:(NSString *)typeTitle{
    _typeTitle = typeTitle;
    self.titleLabel.text = typeTitle;
}

-(void)setPlanDate:(NSString *)planDate{
    _planDate = planDate;
    [self.dateBtn setTitle:[NSString stringWithFormat:@"计划入院日期：%@",planDate] forState:UIControlStateNormal];
}

-(void)setPatientDic:(NSDictionary *)patientDic{
    _patientDic = patientDic;
    self.nameLabel.text = patientDic[@"realname"];
    self.ageLabel.text = [NSString stringWithFormat:@"%@ %@岁",patientDic[@"gender"],patientDic[@"age"]];
    [self.numberBtn setTitle:LGNSString(patientDic[@"hospital_bano"]) forState:UIControlStateNormal];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self addSubview:self.titleLabel];
    [self addSubview:self.dateBtn];
    [self addSubview:self.nameIcon];
    [self addSubview:self.nameLabel];
    [self addSubview:self.ageLabel];
    [self addSubview:self.numberBtn];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameIcon.mas_right).offset(4);
        make.centerY.equalTo(self.nameIcon);
    }];
    [self.ageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_right).offset(6);
        make.centerY.equalTo(self.nameIcon);
        make.width.equalTo(@(66));
        make.height.equalTo(@(22));
    }];
    [self.numberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.ageLabel.mas_right).offset(24);
        make.width.equalTo(@(viewPix(120)));
        make.height.equalTo(@(22));
        make.centerY.equalTo(self.nameIcon);
    }];
}
-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
        _titleLabel.frame = CGRectMake(viewPix(16), viewPix(14), Screen_W-viewPix(64), 22);
    }
    return _titleLabel;
}

-(UIButton *)dateBtn{
    if(!_dateBtn){
        _dateBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(14) textColor:@"#666666" imageName:@"我的订单-订单时间"];
        _dateBtn.frame = CGRectMake(viewPix(16), kMaxY(self.titleLabel.frame)+viewPix(10), Screen_W-viewPix(64), 20);
        _dateBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _dateBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    }
    return _dateBtn;
}

-(UIImageView *)nameIcon{
    if(!_nameIcon){
        _nameIcon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"计划入院-姓名"]];
        _nameIcon.frame = CGRectMake(viewPix(16), kMaxY(self.dateBtn.frame)+viewPix(13), viewPix(16), viewPix(16));
    }
    return _nameIcon;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)ageLabel{
    if(!_ageLabel){
        _ageLabel = [UILabel lableWithText:@"" colorString:@"#2E9AFC" textFont:LGFont(14) textAlignment:NSTextAlignmentCenter lines:1];
        _ageLabel.backgroundColor = [UIColor colorWithString:@"#EAF4FF"];
        _ageLabel.cornerRidus = 11;
    }
    return _ageLabel;
}

-(UIButton *)numberBtn{
    if(!_numberBtn){
        _numberBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(16) textColor:@"#666666" imageName:@"计划入院-ID"];
        _numberBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _numberBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 0);
    }
    return _numberBtn;
}



@end
